package kcms.course.action;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

import javax.annotation.Resource;

import kcms.course.service.CourseService;
import kcms.db.CourseJiaoke;
import kcms.db.User;


import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Controller("CourseAction")
@Scope("prototype")
public class CourseAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	@Resource
	private CourseService courseservice;
	private User user;
	private String[] checkbox;
	private List<CourseJiaoke> cr;
	private List<CourseJiaoke> cr2;
	//老师选择自己所教授的课程
	public String displayAllCourse(){
		user=(User) ActionContext.getContext().getSession().get("user");
		cr=courseservice.getAllCourseTeachBy(user);
		//System.out.println(cr.get(1).getCsn());
		return "success";
	}
	//勾选需要上传的课程
	public String submitCourseList(){
		cr2=new ArrayList();
		String temp[];
		for(String ckb:checkbox){
			temp=ckb.split("@");
			
			cr2.add(this.courseservice.getByCidCsn(temp[0],temp[1]));
		}
		return "checksuccess";
	}
	
	public CourseService getCourseservice() {
		return courseservice;
	}
	public void setCourseservice(CourseService courseservice) {
		this.courseservice = courseservice;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public List<CourseJiaoke> getCr() {
		return cr;
	}
	public void setCr(List<CourseJiaoke> cr) {
		this.cr = cr;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String[] getCheckbox() {
		return checkbox;
	}
	public void setCheckbox(String[] checkbox) {
		this.checkbox = checkbox;
	}
	public List<CourseJiaoke> getCr2() {
		return cr2;
	}
	public void setCr2(List<CourseJiaoke> cr2) {
		this.cr2 = cr2;
	}
	
	
	
	

	

	/*public PptService getPptservice() {
		return pptservice;
	}

	public void setPptservice(PptService pptservice) {
		this.pptservice = pptservice;
	}*/

	/*public static long getSerialversionuid() {
		return serialVersionUID;
	}  */ 
	
	
	
	
}
